Skip to content

Conversation

mmmsssttt404
Copy link

I am writing to report a potential Regular Expression Denial of Service (ReDoS) vulnerability or Inefficient Regular Expression in the project. When using specially crafted input strings in the context, it may lead to extremely high CPU usage, application freezing, or denial of service attacks.

.replace(/(\[)(?=[^/]+\])/g, '[[]') // escape '[' when ']' follows within the path segment

change to:
https://github.com/mmmsssttt404/toolkit/blob/f1d6d994406ccf553f554631c8aeff565b051950/packages/glob/src/internal-pattern.ts#L191

Describe the steps to verify that the changes are working as expected.

1.git clone https://github.com/mmmsssttt404/toolkit.git
2.cd toolkit
3.npm install
4.npm run build
5.npx tsc
6.npm test -- packages/glob/tests/internal-pattern.test.ts

{568630AE-CE1C-45CF-8AB7-D0027F02C32E}

before change:

屏幕截图 2025-05-13 160742 屏幕截图 2025-05-13 161631

after change:
屏幕截图 2025-05-13 162517
屏幕截图 2025-05-13 162554

@mmmsssttt404 mmmsssttt404 requested a review from a team as a code owner May 13, 2025 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants